import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;

public class TextArrayList {
    public static void main(String[] args) {

        List<Integer> list = new ArrayList<>();
        int[] arr = new int[100];
        Random random = new Random();
        int count = 0;
        //随机生成100名囚犯的号码
        out:
        for (int i = 0; i < 100; i++) {

            int number = random.nextInt(200)+1;
            for (int j = 0; j <= count; j++) {
                if (arr[j] == number){
                    i--;
                    continue out;
                }
            }
            count++;
            arr[i] = number;
            list.add(number);
        }
        System.out.println(list);

        //去掉站在奇数位置的号码,从1开始，其实就是要删除偶数位置的号码
            int count1 = 100;
        while (list.size() != 3) {
            for (int i = 0; i < count1/2; i++) {
                list.remove(i);
            }
            count1 = count1 / 2;
        }
        System.out.println(list);
        int finalNumber = list.get(1);
        System.out.println(finalNumber);

        int index1 = 0;
        for (int i = 0; i < 100; i++) {
            if (arr[i]==finalNumber){
                index1 = i;
                break;
            }
        }
        System.out.println(index1);
    }
}
